package com.sh.data.engine.application.model.request.integration;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * @author : changkong
 * @date : 2022/3/15
 */
@Data
@Builder
@Schema(description = "保存任务请求")
@NoArgsConstructor
@AllArgsConstructor
public class SaveHttpTaskRequest {

    /**
     *
     */
    @Schema(description = "任务id")
    private Long id;

    @Schema(description = "任务名称", required = true)
    @NotBlank
    @Pattern(
        regexp = "^[\\u4e00-\\u9fa5_a-zA-Z0-9]{2,32}$",
        message = "任务名称长度在2-32之间, 仅支持中文英文字母数字下划线")
    private String taskName;

    // api相关
    @Schema(description = "api参数", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull
    @Valid
    private TestApiHttpRequest apiHttpRequest;

    @Schema(description = "api返回值配置", requiredMode = Schema.RequiredMode.REQUIRED)
    @Valid
    @NotNull
    private PreviewExpressRequest previewExpressRequest;

    // 任务配置相关
    @NotNull
    @Valid
    @Schema(description = "字段配置,表配置", requiredMode = Schema.RequiredMode.REQUIRED)
    private TaskConfigRequest taskConfigRequest;
}
